import request from "./request/index.js";

export async function addCustomer(data) {
    try {
        const res = await request.post("/customer", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function listCustomers(data) {
    try {
        const res = await request.post("/customer/list", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function getCustomer(id) {
    try {
        const res = await request.get(`/customer/${id}`);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function updateCustomer(data) {
    try {
        const res = await request.put("/customer", data);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

export async function deleteCustomer(id) {
    try {
        const res = await request.delete(`/customer/${id}`);
        return res.data;
    } catch (err) {
        return Promise.reject(err);
    }
}

